package com.kongxx.struts2study.jfreechart.web.action;

import com.opensymphony.xwork2.ActionSupport;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.DefaultCategoryDataset;

public class MyBarChart1Action extends ActionSupport {

	private JFreeChart chart;

	public String execute() throws Exception {
		DefaultCategoryDataset dataset = new DefaultCategoryDataset();
		dataset.addValue(23.0D, "Series 1", "London");
		dataset.addValue(14.0D, "Series 1", "New York");
		dataset.addValue(14.0D, "Series 1", "Istanbul");
		dataset.addValue(14.0D, "Series 1", "Cairo");
		dataset.addValue(13.0D, "Series 2", "London");
		dataset.addValue(19.0D, "Series 2", "New York");
		dataset.addValue(19.0D, "Series 2", "Istanbul");
		dataset.addValue(19.0D, "Series 2", "Cairo");
		dataset.addValue(7.0D, "Series 3", "London");
		dataset.addValue(9.0D, "Series 3", "New York");
		dataset.addValue(9.0D, "Series 3", "Istanbul");
		dataset.addValue(9.0D, "Series 3", "Cairo");
		// chart = ChartFactory.createBarChart("2D Bar Chart Demo", "Category", "Value", dataset, PlotOrientation.VERTICAL, true, true, false);
		// chart = ChartFactory.createBarChart("2D Bar Chart Demo", "Category", "Value", dataset, PlotOrientation.HORIZONTAL, true, true, false);
		// chart = ChartFactory.createBarChart3D("3D Bar Chart Demo", "Category", "Value", dataset, PlotOrientation.VERTICAL, true, true, false);
		chart = ChartFactory.createBarChart3D("3D Bar Chart Demo", "Category", "Value", dataset, PlotOrientation.HORIZONTAL, true, true, false);
		return SUCCESS;
	}

	public JFreeChart getChart() {
		return chart;
	}

	public void setChart(JFreeChart chart) {
		this.chart = chart;
	}
}
